#include "stdafx.h"
#include <boost/test/auto_unit_test.hpp>

#include <boost/test/execution_monitor.hpp>
#include "bmock.hpp"
#include "bmock_control_tools_mock.hpp"

struct abs_class {
	abs_class(int x){id=x;}
	virtual            ~abs_class(){id=0;}
	virtual void set_id(int x)=0;
	int id;
protected:
	
	
};

struct abs_class1:public abs_class {
	abs_class1(int x,int s);
	virtual            ~abs_class1(){id1=0;}
	 void set_id(int x){id=x;}
	 int id1;
protected:
	


};

abs_class1::abs_class1(int x,int s)
:abs_class(x)

{id1=s;}

namespace std {
	inline ostream &operator <<(ostream &os,const abs_class &td) {
		os<<td.id;
		return os;
	}
	inline istream &operator >>(istream &is,abs_class &td) {
		is>>td.id; 
		return is;
	}
}

namespace std {
	inline ostream &operator <<(ostream &os,const abs_class1 &td) {
		os<<td.id<<' '<<td.id1;
		return os;
	}
	inline istream &operator >>(istream &is,abs_class1 &td) {
		char blank;
		is>>td.id;
		is>>blank;
		is>>td.id1; 
		return is;
	}
}

static void g(abs_class& x) {
	STATIC_MOCK_VOID(1, (IN(x)));
}
static void k(abs_class1& x) {
	STATIC_MOCK_VOID(1, (IN(x)));
}

static abs_class1 l(8,9);
static abs_class1 p(8,9);





BOOST_AUTO_TEST_CASE(testReferenceToAbstractClassSameObject) {
	__BMOCK_CONTROL(c);
	__BMOCK_EXPECT_C(c,g(l));
	__BMOCK_REPLAY_C(c);
	BOOST_CHECK_NO_THROW(g(l));
	__BMOCK_VERIFY_C(c);
}

BOOST_AUTO_TEST_CASE(testReferenceToAbstractClassDifferenteObject) {
	__BMOCK_CONTROL(c);
	__BMOCK_EXPECT_C(c,g(l));
	__BMOCK_REPLAY_C(c);
	BOOST_CHECK_NO_THROW(g(p));
	__BMOCK_VERIFY_C(c);
}

BOOST_AUTO_TEST_CASE(testReferenceToNotAbstractClassSameObject) {
	__BMOCK_CONTROL(c);
	__BMOCK_EXPECT_C(c,k(l));
	__BMOCK_REPLAY_C(c);
	BOOST_CHECK_NO_THROW(k(l));
	__BMOCK_VERIFY_C(c);
}
BOOST_AUTO_TEST_CASE(testReferenceToNotAbstractClassDifferenteObject) {
	__BMOCK_CONTROL(c);
	__BMOCK_EXPECT_C(c,k(l));
	__BMOCK_REPLAY_C(c);
	BOOST_CHECK_NO_THROW(k(p));
	__BMOCK_VERIFY_C(c);
}

